package com.example.consult.mapper;

import com.example.consult.model.UserInfo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface UserMapper {

    //登录
    @Select("select * from user_info where user_account=#{userAccount} and user_pwd=#{userPwd}")
    public UserInfo searchByUserAccountAndPassword(String userAccount,String userPwd);

    //注册
    @Insert("insert into user_info(user_Id,user_account,user_name,user_pwd) values(#{user_id},#{user_account},#{user_name},#{user_pwd})")
    public int insertUser(UserInfo userInfo);

    //根据userAccount查重
    @Select("select count(*) from user_info where user_account=#{userAccount}")
    public int searchByUserAccount(String userAccount);

    @Update("update user_info SET user_pwd = #{user_pwd},user_name=#{user_name},email=#{email},phoneNumber=#{phoneNumber}")
    public int updateUserInfo(UserInfo userInfo);

    @Select("select * from user_info")
    public List<UserInfo> getAll();

}
